package com.bbx.taxi.client.widget.Drag;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.baidu.mapapi.map.MapView;
import com.bbx.api.sdk.model.passanger.Return.Elements;
import com.bbx.api.sdk.model.passanger.Return.PriceDetail;
import com.bbx.api.sdk.model.passanger.Return.ShareDetail;
import com.bbx.api.sdk.model.passanger.Return.UsableSale;
import com.bbx.api.sdk.model.passanger.Return.CarType.CarType;
import com.bbx.taxi.client.R;
import com.bbx.taxi.client.R.string;
import com.bbx.taxi.client.Activity.Main.IMainContract;
import com.bbx.taxi.client.Activity.Main.MainPresenter;
import com.bbx.taxi.client.Activity.Main.MainPresenter.OnCouponFinish;
import com.bbx.taxi.client.Adapter.PayAdapter;
import com.bbx.taxi.client.Adapter.PayDetailsAdapter;
import com.bbx.taxi.client.Util.CouponUtils;
import com.bbx.taxi.client.Util.FormatUtil;
import com.bbx.taxi.client.Util.FastBlur.BlurBuilder;
import com.bbx.taxi.client.Util.FastBlur.BlurBuilder.OnBlurFinishListener;
import com.bbx.taxi.client.Util.FastBlur.BlurBuilder.OnSnapShotFinishListener;
import com.bbx.taxi.client.widget.pop.SharePopView.OnShareDetaiFinish;
import com.yanxuwen.loadview.LoadingDialog;

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.media.Image;
import android.os.Handler;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.ViewDragHelper;
import android.text.Html;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

/** 
 * @Path com.bbx.taxi.client.widget.Drag.AddFareDragLayout.java
 * @Author 严旭文
 * @Date 2016-11-21 下午4:07:01
 * @Company 蓝海（福建）信息技术有限公司
 * @Description
 */
public class AddFareDragLayout  extends BaseDragLayout implements OnCouponFinish{
	/*-----------------------试图--------------------------------*/
	private TextView tv_base_price;
	private TextView tv_base_discount;
	private TextView tv_coupon;
	private Button cancel,confirm;
	private ImageView iv_left;
	private TextView tv_pay;
	private IMainContract.Presenter mPresenter;
	LoadingDialog mLoadingDialog;
	public AddFareDragLayout(Context context) {
		super(context);
	}

	public AddFareDragLayout(Context context, AttributeSet attrs) {
		super(context, attrs, 0);
	}

	public AddFareDragLayout(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}
	@Override
	public void initView() {
		setContentView(findViewById(R.id.desc_add_fare));

		tv_base_price=(TextView)getContentView().findViewById(R.id.tv_base_price);
		tv_base_discount=(TextView)getContentView().findViewById(R.id.tv_base_discount);
		tv_coupon=(TextView)getContentView().findViewById(R.id.tv_coupon);
		cancel=(Button)getContentView().findViewById(R.id.cancel);
		confirm=(Button)getContentView().findViewById(R.id.confirm);
		iv_left=(ImageView)getContentView().findViewById(R.id.iv_left);
		tv_pay = (TextView) getContentView().findViewById(R.id.tv_pay);
		tv_pay.setTextColor(context.getResources().getColor(R.color.red));
		ImageView iv_biaozhi=(ImageView)getContentView().findViewById(R.id.iv_biaozhi);
		iv_biaozhi.setVisibility(View.GONE);
		iv_left.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				close();
			}
		});
		cancel.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				close();
			}
		});
		confirm.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				close();
				mPresenter.onOrderSubmit();
			}
		});
	
	}
    /**
     * @param mPresenter
     * @param actual_price   需要支付价钱
       @param base_price     单位分
     * @param base_discount  >1代表1.N倍，，<1代表0.N折
     * @param coupon
     * @param sale_type
     */
    public void setDetail(IMainContract.Presenter mPresenter,double actual_price,double base_price,double base_discount,double coupon,int sale_type){
    	this.mPresenter=mPresenter;
    	tv_pay.setText(FormatUtil.onFormatPrice(actual_price));
    	tv_base_price.setText(Html.fromHtml(String.format(context.getString(R.string.addfare_base_price),"<font color=\"#ff4343\">"+FormatUtil.onFormatPrice(base_price)+"</font>")));
    	tv_base_discount.setText(base_discount+"");
    	switch(sale_type){
    	case UsableSale.sale_type_no:
        	tv_coupon.setText(Html.fromHtml(String.format(context.getString(R.string.addfare_coupon),"<font color=\"#ff4343\">"+FormatUtil.onFormatPrice(coupon)+"</font>")));
    		break;
    	case UsableSale.sale_type_submit:
        	tv_coupon.setText(Html.fromHtml(String.format(context.getString(R.string.addfare_coupon_sale_submit),"<font color=\"#ff4343\">"+FormatUtil.onFormatPrice(coupon)+"</font>")));
    		break;
    	case UsableSale.sale_type_online:
        	tv_coupon.setText(Html.fromHtml(String.format(context.getString(R.string.addfare_coupon_sale_online),"<font color=\"#ff4343\">"+FormatUtil.onFormatPrice(coupon)+"</font>")));
    		break;
    	}
    	if(coupon==0){
    		tv_coupon.setVisibility(View.GONE);
    	}else{
      		tv_coupon.setVisibility(View.VISIBLE);
    	}
    }
	public void setLoadView(LoadingDialog mLoadingDialog){
		this.mLoadingDialog=mLoadingDialog;
		if(mLoadingDialog!=null&&!mLoadingDialog.isShowing()){
			mLoadingDialog.show();
		}
	}
	@Override
	public void onCouponFinish(double coupon_sum) {
	}

	@Override
	protected void onViewStatus(boolean isOpen) {
		// TODO Auto-generated method stub
		
	}
}
